name: Lint on push or pull request

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

env:
  POETRY_VERSION: "1.6.1"

jobs:
  linting-ts:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: 'admin'
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "18"

      - name: Install dependencies
        run: npm install

      - name: Run lint
        run: npm run lint

      - name: Run Prettier
        run: npm run format
  
  linting-python:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.11"]
    steps:
      - uses: actions/checkout@v4

      - name: Set up python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install Poetry
        uses: snok/install-poetry@v1
        with:
          version: ${{ env.POETRY_VERSION }}

      - name: Install pre-commit
        shell: bash
        run: poetry install --with dev

      - name: Run formatter
        shell: bash
        run: poetry run black --check .
